package kz.simplex.photobox.model;
// Generated Jul 19, 2009 4:45:38 PM by Hibernate Tools 3.2.2.GA

import static javax.persistence.GenerationType.IDENTITY;

import java.util.Date;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;

/**
 * Albums generated by hbm2java
 */
@Entity
@Table(name = "albums", catalog = "photobox")
public class Album implements java.io.Serializable {
	private Integer id;
	private User owner;
	private Category category;
	private String title;
	private String description;
	private Date created = new Date();
	private Date lastupdated;
	private Access access;
	private boolean published;
	private Set<Tag> tags;
	private Set<Photo> photos;
	
	public Album() {
	}

	public Album(User owner, String title, Date created, Date lastupdated,
			Access access, boolean published) {
		this.owner = owner;
		this.title = title;
		this.created = created;
		this.lastupdated = lastupdated;
		this.access = access;
		this.published = published;
	}
	public Album(User owner, Category category, String title, String description,
			Date created, Date lastupdated, Access access, boolean published, Set<Photo> photos) {
		this.owner = owner;
		this.category = category;
		this.title = title;
		this.description = description;
		this.created = created;
		this.lastupdated = lastupdated;
		this.access = access;
		this.published = published;
		this.photos = photos;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne
	@JoinColumn(name="owner", referencedColumnName="id", nullable = false)
	public User getOwner() {
		return this.owner;
	}
	public void setOwner(User owner) {
		this.owner = owner;
	}

	@ManyToOne
	@JoinColumn(name="category", referencedColumnName="id", nullable = true)
	public Category getCategory() {
		return this.category;
	}
	public void setCategory(Category category) {
		this.category = category;
	}

	@Column(name = "title", nullable = false, length = 256)
	@NotNull
	@Length(max = 256)
	public String getTitle() {
		return this.title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	@Column(name = "dsc", length = 65535)
	@Length(max = 65535)
	public String getDescription() {
		return this.description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "created", nullable = false, length = 19)
	@NotNull
	public Date getCreated() {
		return this.created;
	}

	public void setCreated(Date created) {
		this.created = created;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "lastupdated", nullable = false, length = 19)
	@NotNull
	public Date getLastupdated() {
		return this.lastupdated;
	}

	public void setLastupdated(Date lastupdated) {
		this.lastupdated = lastupdated;
	}

	@ManyToOne
	@JoinColumn(name="access", referencedColumnName="id", nullable = false)
	public Access getAccess() {
		return this.access;
	}
	public void setAccess(Access access) {
		this.access = access;
	}

	@Column(name = "published", nullable = false)
	public boolean getPublished() {
		return this.published;
	}
	public void setPublished(boolean published) {
		this.published = published;
	}

	@ManyToMany(mappedBy="albums")
	public Set<Tag> getTags() {
		return tags;
	}
	public void setTags(Set<Tag> tags) {
		this.tags = tags;
	}

	@OneToMany(mappedBy="album")
	public Set<Photo> getPhotos() {
		return photos;
	}
	public void setPhotos(Set<Photo> photos) {
		this.photos = photos;
	}
	
}
